//作业1:
//reverse1和reverse2执行过程（m=list(1,2,3,4)
//reverse1(递归):
//[1，null]=>[2,[1,null]]=>[3,[2,[1,null]]]=>[4,[3,[2,[1,null]]]]

//reverse2(迭代)：
//[1，null]=>[2,result=[1,null]]=>[3,result=[2,[1,null]]]=>[4,result=[3,[2,[1,null]]]]=>[4,[3,[2,[1,null]]]]

//作业2:
//m=list(1,3,5,7,9)要实现的结果为[1,[9,[25,[49,[81,null]]]]]
function squareList1(items) {
    return iter(items);  
    function iter(items, result = null) {
      if (isNull(items)) return result;
      //result改成reverse(result),如不改，结果为[81,[49,[25,[9,[1,null]]]]]
      return iter(tail(items), pair(head(items) ** 2, result));
    }
}
  function squareList2(items) {
    return iter(items);
  
    function iter(items, result = null) {
      if (isNull(items)) return result;
      ////result改成reverse(result)
      return iter(tail(items), pair(result, head(items) ** 2));
      //pair(result, head(items) ** 2)改成pair(head(items) ** 2, result)
    }//如不改，结果为[[[[[null,1],9],25],49],81]
  }

